<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head th:replace="_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title th:text="${blog.title}">博客详情</title>
    <link rel="stylesheet" href="../static/dist/semantic/semantic.min.css">
    <link rel="stylesheet" href="../static/css/typo.css">
    <link rel="stylesheet" href="../static/lib/prism/prism.css">
    <link rel="stylesheet" href="../static/lib/tocbot/tocbot.css">
    <link rel="stylesheet" href="../static/css/me.css">
</head>

<body class="Site">
    <!-- 导航 -->
    <section id="home" th:style="'background:url(' + ${blog.firstPicture}+') no-repeat center;'">
        <nav class="ui segment attached m-padded-tb-mini m-background-small m-fixed m-top m-height" style="z-index: 2" th:replace="_fragments :: menu(0)">
            <div class="ui secondary stackable menu m-margin-tb-mini">
                <h2 class="ui brown header item m-padded-mini">猪油骨</h2>
                <a href="#" class="right m-item item m-mobile-hide  m-padded-tb-small"><svg class="icon1" aria-hidden="true">
                    <use xlink:href="#icon-shouye"></use>
                </svg>首页</a>
                <a href="#" class="m-item item m-mobile-hide m-padded-tb-small"><svg class="icon1" aria-hidden="true">
                    <use xlink:href="#icon-fenlei1"></use>
                </svg> 分类</a>
                <a href="#" class="m-item item m-mobile-hide  m-padded-tb-small"><svg class="icon1" aria-hidden="true">
                    <use xlink:href="#icon-_biaoqian"></use>
                </svg> 标签</a>
                <a href="#" class="m-item item m-mobile-hide  m-padded-tb-small"><svg class="icon1" aria-hidden="true">
                    <use xlink:href="#icon-guidangrizhi"></use>
                </svg>归档</a>
                <a href="#" class="m-item item m-mobile-hide  m-padded-tb-small"><svg class="icon1" aria-hidden="true">
                    <use xlink:href="#icon-guanyuwomen2"></use>
                </svg>关于我</a>
                <a href="#" class="ui button m-item item m-mobile-hide m-padded-mini"><svg class="icon1" aria-hidden="true">
                    <use xlink:href="#icon-sousuo1"></use>
                </svg>搜索</a>
            </div>
            <div class="ui modal m-container-mini">
                <i class="close icon"></i>
                <h2 class="ui grey header item ">请输入搜索内容</h2>
                <div class=" ui right icon input">
                    <input type="text" placeholder="搜索....">
                    <i class="search link icon"></i>
                </div>
            </div>
            </div>
            <a href="#" class="ui menu toggle black icon button m-right-top m-mobile-show"
               style="background: rgba(0,0,0,0)"><i class="sidebar icon"></i></a>
        </nav>
        <div class="inner-width animated zoomIn">
            <div class="content">
                <h2 class="ui center aligned header m-weight-none " style="color:#fff ;font-size: xx-large" th:text="${blog.title}">鸡汤</h2>
                <h3 class="m-weight-none"><div class="ui horizontal link list">
                    <div class="item">
                        <div class="content"><a herf="#"  class="header" th:text="${blog.user.nickname}">CodeSleep</a></div>
                    </div>
                    <div class="item">
                        <i class="calendar icon"></i><span th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd')}">2022/11/11</span>
                    </div>
                    <div class="item">
                        <i class="eye icon"></i> <span th:text="${blog.views}">2200</span>
                    </div>
                </div></h3>
                <div class="buttons m-margin-tb-tiny disabled">

                </div>
            </div>
        </div>
    </section>
    <!-- 中间 -->
    <div id="waypoint" class="m-container-small m-padded-tb-big animate__animated animate__fadeIn">
        <div class="ui container">
            <!--图片区域-->
            <!--内容-->
            <div class="ui padded segment">
                <div class="ui right aligned basic segment">
                    <div class="ui orange basic label" th:text="${blog.flag}">转载</div>
                </div>
                <br>
                <div id="content" class="typo  typo-selection js-toc-content m-padded-lr-responsive m-padded-tb-large" th:utext="${blog.content}">

                    <h5 id="appendix2">2、开源许可</h5>
                </div>
                <!-- 标签 -->
                <div class="m-padded-lr-responsive">
                    <div class="ui basic teal left pointing label" th:each="tag : ${blog.tags}" th:text="${tag.name}">方法论</div>
                </div>
                <!--赞赏-->
                <div th:if="${blog.appreciation}">
                    <div class="ui center aligned basic segment">
                        <button id="payButton" class="ui orange basic circular button">赞赏</button>
                    </div>
                    <div class="ui payQR flowing popup transition hidden">
                        <div class="ui orange basic label">
                            <div class="ui images" style="font-size: inherit !important;">
                                <div class="image">
                                    <img src="../static/images/Cache_-79d079ba8ca743f7..jpg" alt=""  class="ui rounded bordered image" style="width: 120px" th:src="@{/images/weixinzhifu.png}">
                                    <div>微信</div>
                                </div>
                                <div class="image">
                                    <img src="../static/images/Cache_-79d079ba8ca743f7..jpg" alt="" class="ui rounded bordered image" style="width: 120px" th:src="@{/images/zhifubao.jpg}">
                                    <div>支付宝</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>


            <!--博客信息-->
            <div class="ui attached positive message" th:if="${blog.shareStatement}">
                <div class="ui middle aligned grid">
                    <div class="eleven wide column">
                        <ui class="list">
                            <li>作者：<span th:text="${blog.user.nickname}">猪油骨</span><a href="#" th:href="@{/about}" target="_blank">（联系作者）</a></li>
                            <li>发表时间：<span th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd HH:mm')}">2020-10-02 14:49</span></li>
                            <li>版权声明：自由转载-非商用-非衍生-保持署名</li>
                            <li>公众号转载：请在文末添加作者公众号二维码</li>
                        </ui>
                    </div>

                    <div class="five wide column">
                        <img src="../static/images/Cache_-79d079ba8ca743f7..jpg" alt="" th:src="@{/images/gongzhonghao.jpg}" class="ui right floated rounded bordered image" style="width: 120px">
                    </div>
                </div>
            </div>
            <div class="ui bottom attached segment " th:if="${blog.commentTabled}">
                <!--留言区域列表-->
                <div id="comment-container"  class="ui teal segment">
                    <div th:fragment="commentList">
                        <div class="ui comments" style="max-width: 100%">
                            <h3 class="ui dividing header" >评论</h3>
                            <div class="comment" th:each="comment : ${comments}">
                                <a class="avatar">
                                    <img src="../static/images/Cache_-79d079ba8ca743f7..jpg" th:src="@{${comment.avatar}}">
                                </a>
                                <div class="content">
                                    <a class="author">
                                        <span th:text="${comment.nickname}">猪</span>
                                        <div class="ui mini basic teal left pointing label m-padded-mini"  th:if="${comment.adminComment}">博主</div>
                                    </a>
                                    <div class="metadata">
                                        <span class="date" th:text="${#dates.format(comment.createTime,'yyyy-MM-dd HH:mm')}">Today at 5:42PM</span>
                                    </div>
                                    <div class="text" th:text="${comment.content}">
                                        How artistic!
                                    </div>
                                    <div class="actions">
                                        <a class="reply" data-commentid="1" data-commentnickname="Matt" th:attr="data-commentid=${comment.id},data-commentnickname=${comment.nickname}" onclick="reply(this)">回复</a>
                                    </div>
                                </div>
                                <div class="comments" th:if="${#arrays.length(comment.replyComments)}>0">
                                    <div class="comment" th:each="reply : ${comment.replyComments}">
                                        <a class="avatar">
                                            <img src="../static/images/Cache_-79d079ba8ca743f7..jpg" th:src="@{${reply.avatar}}">
                                        </a>
                                        <div class="content">
                                            <a class="author">
                                                <span th:text="${reply.nickname}">小红</span>
                                                <div class="ui mini basic teal left pointing label m-padded-mini" th:if="${reply.adminComment}">博主</div>
                                                &nbsp;<span th:text="|@ ${reply.parentComment.nickname} |" class="m-teal">@ 小黄</span>
                                            </a>
                                            <div class="metadata">
                                                <span class="date" th:text="${#dates.format(reply.createTime,'yyyy-MM-dd HH:mm')}">Today at 5:42PM</span>
                                            </div>
                                            <div class="text" th:text="${reply.content}">
                                                How artistic!
                                            </div>
                                            <div class="actions">
                                                <a class="reply" data-commentid="1" data-commentnickname="Matt" th:attr="data-commentid=${reply.id},data-commentnickname=${reply.nickname}" onclick="reply(this)">回复</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                           <!--/*-->
                            <div class="comment">
                                <a class="avatar">
                                    <img src="../static/images/Cache_-79d079ba8ca743f7..jpg" th:src="@{/images/Cache_-79d079ba8ca743f7..jpg}">
                                </a>
                                <div class="content">
                                    <a class="author">Elliot Fu</a>
                                    <div class="metadata">
                                        <span class="date">Yesterday at 12:30AM</span>
                                    </div>
                                    <div class="text">
                                        <p>This has been very useful for my research. Thanks as well!</p>
                                    </div>
                                    <div class="actions">
                                        <a class="reply">回复</a>
                                    </div>
                                </div>
                                <div class="comments">
                                    <div class="comment">
                                        <a class="avatar">
                                            <img src="../static/images/Cache_-79d079ba8ca743f7..jpg" th:src="@{/images/Cache_-79d079ba8ca743f7..jpg}">
                                        </a>
                                        <div class="content">
                                            <a class="author">Jenny Hess</a>
                                            <div class="metadata">
                                                <span class="date">Just now</span>
                                            </div>
                                            <div class="text">
                                                Elliot you are always so right :)
                                            </div>
                                            <div class="actions">
                                                <a class="reply">回复</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="comment">
                                <a class="avatar">
                                    <img src="../static/images/Cache_-79d079ba8ca743f7..jpg" alt="" th:src="@{/images/Cache_-79d079ba8ca743f7..jpg}">
                                </a>
                                <div class="content">
                                    <a class="author">Joe Henderson</a>
                                    <div class="metadata">
                                        <span class="date">5 days ago</span>
                                    </div>
                                    <div class="text">
                                        Dude, this is awesome. Thanks so much
                                    </div>
                                    <div class="actions">
                                        <a class="reply">回复</a>
                                    </div>
                                </div>
                            </div>
                            <!--*/-->
                        </div>
                    </div>
                </div>
                <div id="comment-form" class="ui form">
                    <input type="hidden" name="blog.id" th:value="${blog.id}">
                    <input type="hidden" name="parentComment.id" th:value="-1">
                    <div class="field">
                        <textarea name="content" placeholder="请输入评论信息...."></textarea>
                    </div>
                    <div class="fields">
                        <div class="field m-mobile-wide m-margin-bottom-small">
                            <div class="ui left icon input">
                                <i class="user icon "></i>
                                <input type="text" name="nickname" placeholder="姓名"  th:value="${session.user}!=null ? ${session.user.nickname}">
                            </div>
                        </div>

                        <div class="field m-mobile-wide m-margin-bottom-small">
                            <div class="ui left icon input">
                                <i class="mail icon"></i>
                                <input type="text" name="email" placeholder="邮箱" th:value="${session.user}!=null ? ${session.user.email}">
                            </div>
                        </div>
                        <div class="field m-mobile-wide m-margin-bottom-small">
                            <button id="commentpost-btn" type="button" class="ui teal button m-mobile-wide"><i class="edit icon"></i>发布</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="toolbar" class="m-padded  m-fixed m-right-bottom" style="display: none;">
        <div class="ui vertical icon buttons">
            <button type="button" class="ui toc teal button">目录</button>
            <a href="#comment-container" class="ui teal button">留言</a>
            <button id="toTop-button" class="ui icon button"><i class="chevron up icon"></i></button>
        </div>
    </div>

    <div class="ui toc-container flowing popup transition hidden" style="width: 250px">
        <ol class="js-toc">
        </ol>
    </div>

    <div id="qrcode" class="ui weChatQR flowing popup transition hidden " style="width: 130px !important;">
    </div>


    <!-- 底部 -->
    <footer th:replace="_fragments :: footer" class="ui inverted vertical segment m-padded-tb-massive">
        <div class="ui center aligned container">
            <div class="ui inverted divided stackable grid">
                <div class="three wide column">
                    <div class="ui inverted link list">
                        <div class="item">
                            <img src="../static/images/Cache_-79d079ba8ca743f7..jpg" class="ui rounded image" alt=""
                                 style="width: 110px;" th:src="@{/images/Cache_-79d079ba8ca743f7..jpg}">
                        </div>
                    </div>
                </div>
                <div class="three wide column">
                    <h4 class="ui center aligned inverted header m-text-thin m-text-spaced">最新博客</h4>
                    <div class="ui inverted link list">
                        <a href="#" class="item">用户故事(User Story)</a>
                        <a href="#" class="item">用户故事(User Story)</a>
                        <a href="#" class="item">用户故事(User Story)</a>
                    </div>
                </div>
                <div class="three wide column">
                    <h4 class="ui center aligned inverted header m-text-thin m-text-spaced">联系我</h4>
                    <div class="ui inverted link list">
                        <a href="#" class="item">Email:1937627852@qq.com</a>
                        <a href="#" class="item">QQ:1937627852</a>
                        <a href="#" class="item">微信:zhuyougu10</a>
                    </div>
                </div>
                <div class="seven wide column">
                    <h4 class="ui center aligned inverted header m-text-thin m-text-spaced">声明：</h4>
                    <p class="m-text-thin m-text-spaced m-opacity-mini">此网站只用于交流学习，请勿用作它途。如有侵权，请联系， 删除处理。 </p>
                </div>
            </div>
            <div class="ui inverted section divider"></div>
            <p class="m-text-thin m-text-spaced m-opacity-tiny">Copyright © 2022</p>
        </div>
    </footer>
    <!--/*/<th:block th:replace="_fragments :: script">/*/-->
    <script src="../static/dist/jquery/jquery-3.6.0.min.js"></script>
    <script src="../static/dist/semantic/semantic.min.js"></script>
    <script src="/static/lib/scrollTo/jquery.scrollTo.min.js"></script>
    <script src="/static/lib/prism/prism.js"></script>
    <script src="../static/lib/tocbot/tocbot.min.js"></script>
    <script src="../static/lib/qrcode/qrcode.min.js"></script>
    <script src="../static/lib/waypoints/jquery.waypoints.min.js"></script>
    <!--/*/</th:block>/*/-->

    <script th:inline="javascript">
        tocbot.init({
            // Where to render the table of contents.
            tocSelector: '.js-toc',
            // Where to grab the headings to build the table of contents.
            contentSelector: '.js-toc-content',
            // Which headings to grab inside of the contentSelector element.
            headingSelector: 'h1, h2, h3',
            // For headings inside relative or absolute positioned containers within content.
            hasInnerContainers: true,
        });
        // $('.menu.toggle').click(function () {
        //      $('.m-item').toggleClass('m-mobile-hide');
        // });
        $('#payButton')
            .popup({
                popup: $('.payQR.popup'),
                on: 'click',
                position: 'top center'
            });
        $('.toc.button')
            .popup({
                popup: $('.toc-container.popup'),
                on: 'click',
                position: 'left center'
            });
        $('#toTop-button').click(function () {
            $(window).scrollTo(0,500);
        });
        const waypoint = new Waypoint({
            element: document.getElementById('waypoint'),
            handler: function (direction) {
                if (direction == 'down') {
                    $('#toolbar').show(500);
                } else {
                    $('#toolbar').hide(500);
                }
                console.log('Scrolled to waypoint!' + direction);
            }
        });
        //评论表单验证
        $('.ui.form').form({
            fields: {
                title: {
                    identifier: 'content',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入评论内容'
                    }
                    ]
                },
                content: {
                    identifier: 'nickname',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入你的大名'
                    }]
                },
                type: {
                    identifier: 'email',
                    rules: [{
                        type: 'email',
                        prompt: '请填写正确的邮箱地址'
                    }]
                }
            }
        });

        $(function () {
            $("#comment-container").load(/*[[@{/comments/{id}(id=${blog.id})}]]*/"comments/6");
        });

        $('#commentpost-btn').click(function () {
            var boo = $('.ui.form').form('validate form');
            if (boo) {
                console.log('校验成功');
                postData();
            } else {
                console.log('校验失败');
            }
        });
        function postData() {
            $('#comment-container').load(/*[[@{/comments}]]*/"",{
                "parentComment.id" : $("[name='parentComment.id']").val(),
                "blog.id" : $("[name='blog.id']").val(),
                "nickname": $("[name='nickname']").val(),
                "email"   : $("[name='email']").val(),
                "content" : $("[name='content']").val()
            },function (responseTxt, statusTxt, xhr) {
                // 提交后滚动到这个位置
                // $(window).scrollTo($('#comment-container'),500);
                clearContent();//提交成功后把表单内容清一下
            });
        };
        function clearContent() {
            $("[name='content']").val('');
            $("[name='parentComment.id']").val(-1);
            $("[name='content']").attr("placeholder", "请输入评论信息...");
        };
        function reply(obj) {
            var commentId = $(obj).data('commentid');
            var commentNickname = $(obj).data('commentnickname');
            $("[name='content']").attr("placeholder", "@"+commentNickname).focus();
            $("[name='parentComment.id']").val(commentId);
            $(window).scrollTo($('#comment-form'),500);
        }
        // $(function () {
        //     $(".ui.button.m-item").on("click", function () {
        //         $(".ui.modal").modal("show");
        //     })
        // })




    </script>

</body>

</html>
